package com.guan.util;

import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**‘
 *
 * 简单的MD5加密
 * Created by Administrator on 2018/1/25 0025.
 */
public class Md5Util {
    public static String encodeMd5(String str){
        MessageDigest md5;
        String result = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
            byte[] strResult = md5.digest(str.getBytes());
            BASE64Encoder encoder = new BASE64Encoder();
            result = new String(encoder.encode(strResult));
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return result;
    }
    public static void main(String [] args){
       System.out.print(encodeMd5("guanym[guanym]123456"));
    }
}
